
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2322. -- [BeiJing2011]梦想封印 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2322: [BeiJing2011]梦想封印</h2><span class=green>Time Limit: </span>20 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>97&nbsp;&nbsp;<span class=green>Solved: </span>32<br>[<a href='submitpage.php?id=2322'>Submit</a>][<a href='problemstatus.php?id=2322'>Status</a>][<a href='bbs.php?id=2322'>Discuss</a>]</center><h2>Description</h2><div class=content><h2 style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 12pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></h2>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">渐渐地，</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Magic&nbsp;Land</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">上的人们对那座岛屿上的各种现象有了深入的了解。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为了分析一种奇特的称为梦想封印（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Fantasy&nbsp;Seal</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）的特技，需要引入如下的概念：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">每一位魔法的使用者都有一个&ldquo;魔法脉络&rdquo;，它决定了可以使用的魔法的种类。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">一般地，一个&ldquo;魔法脉络&rdquo;可以看作一个无向图，有</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个结点及</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">条边，将结点编号为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1~N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，其中有一个结点是特殊的，称为</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">核心</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Kernel</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">），</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">记作<font face="Times New Roman">1</font><font face="宋体">号结点</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。每一条边有一个固有（即生成之后再也不会发生变化的）权值，是一个不超过</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">U</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的自然数。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">每一次魔法驱动，可看作是</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">由核心（</span><span style="font-weight: bold; font-size: 12pt; font-style: italic; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">Kernel</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">）出发</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的一条有限长的道路（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Walk</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">），</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">可以经过一条边多次</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，所驱动的魔法类型由以下方式给出：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">将经过的每一条边的权值异或（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">xor</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）起来，得到</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">s</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">如果</span><span style="font-weight: bold; font-size: 12pt; font-style: italic; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">s</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">是</span><span style="font-weight: bold; font-size: 12pt; font-style: italic; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">0</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">，则驱动失败</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，否则将驱动编号为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">s</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的魔法（每一个正整数编号对应了唯一一个魔法）。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">需要注意的是，如果经过了一条边多次，则每一次都要计入<font face="Times New Roman">s</font><font face="宋体">中。</font></span><span style="font-weight: bold; font-size: 12pt; font-family: 'Times New Roman'; text-decoration: underline; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">这样，魔法脉络决定了可使用魔法的类型，当然，由于魔法与其编号之间的关系尚未得到很好的认知，此时人们仅仅关注可使用魔法的种类数。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">梦想封印可以看作是对&ldquo;魔法脉络&rdquo;的破坏：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">该特技作用的结果是，&ldquo;魔法脉络&rdquo;中的一些边逐次地消失。</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"> </span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">我们记总共消失了</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">条边，按顺序依次为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、<font face="Times New Roman">Dis</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、&hellip;&hellip;、<font face="Times New Roman">Dis</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">给定了以上信息，你要计算的是梦想封印作用过程中的效果，这可以用</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q+1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个自然数来描述：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">0</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为初始时可以使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">被破坏（</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">即边被删去</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）后可以使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">及</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">均被破坏后可使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">&hellip;&hellip;</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、&hellip;&hellip;、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">全部被破坏后可以使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<!--EndFragment--></div><h2>Input</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">第一行包含</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">三</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">正</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">整数</span><span style="font-size: 12pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、<font face="Times New Roman">M</font><font face="宋体">、</font><font face="Times New Roman">Q</font></span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来的</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，每行包含</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">3</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个整数，</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ai</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Bi</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，表示一条权为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的与结点</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">A</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">B</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">关联的无向边，其中</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">是不超过</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">U</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的自然数。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">接下来</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，每行一个整数：</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Output</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">一共包</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q+1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，依次为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">0</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、<font face="Times New Roman">Ans</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、&hellip;&hellip;、<font face="Times New Roman">Ans</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<h2 style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></h2></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>【输入样例1】<br />
3 3 2<br />
<br />
1 2 1<br />
<br />
2 3 2<br />
<br />
3 1 4<br />
<br />
1<br />
<br />
3<br />
<br />
【输入样例2】<br />
5 7 7<br />
<br />
1 2 1<br />
<br />
1 3 1<br />
<br />
2 4 2<br />
<br />
2 5 2<br />
<br />
4 5 4<br />
<br />
5 3 9<br />
<br />
4 3 1<br />
<br />
7<br />
<br />
6<br />
<br />
5<br />
<br />
4<br />
<br />
3<br />
<br />
2<br />
<br />
1<br />
<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>【输出样例1】<br />
5<br />
<br />
2<br />
<br />
0<br />
<br />
【样例1解释】<br />
初始时可使用编号为1、3、4、6、7的魔法。<br />
<br />
在删去第1条边（连结1、2结点的边）后，可使用4和6号魔法。<br />
<br />
第3条边（连结第1、3结点的边）也被删去后，核心（Kernel）即结点1孤立，易知此时无法使用魔法。<br />
<br />
【输出样例2】<br />
15<br />
<br />
11<br />
<br />
5<br />
<br />
2<br />
<br />
2<br />
<br />
1<br />
<br />
1<br />
<br />
0<br />
<br />
<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p>【数据规模和约定】<br /><br />
所有数据保证该无向图不含重边、自环。</p><br />
<p>所有数据保证不会有一条边被删除多次，即对于不同i和j，有Disi&ne;Disj</p><br />
<p>30%的数据中N &le; 50，M &le; 50，Q &le;50，U&le;100；</p><br />
<p>60%的数据中N &le; 300，M &le; 300，Q &le;50，U&le;10^9；</p><br />
<p>80%的数据中N &le; 300，M &le; 5000，Q &le;5000，U&le;10^18；</p><br />
<p>100%的数据中N &le; 5000，M &le; 20000，Q &le;20000，U&le;10^18；</p><br />
<p></p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=Day3'>Day3</a></p></div><center>[<a href='submitpage.php?id=2322'>Submit</a>][<a href='problemstatus.php?id=2322'>Status</a>][<a href='bbs.php?id=2322'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
